﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using l1cs.server.model.Instance;

namespace l1cs.server.serverpackets
{
    public class S_DollPack : ServerBasePacket
    {
        private static Logger _log = Logger.getLogger( typeof( S_DollPack ).FullName );
 
        private byte[] _byte = null;

        public S_DollPack( L1DollInstance pet, L1PcInstance player )
        {
            /*
             * int addbyte = 0; int addbyte1 = 1; int addbyte2 = 13; int setting =
             * 4;
             */
            writeC( Opcodes.S_OPCODE_CHARPACK );
            writeH( pet.getX() );
            writeH( pet.getY() );
            writeD( pet.getId() );
            writeH( pet.getGfxId() ); // SpriteID in List.spr
            writeC( pet.getStatus() ); // Modes in List.spr
            writeC( pet.getHeading() );
            writeC( 0 ); // (Bright) - 0~15
            writeC( pet.getMoveSpeed() ); // スピード - 0:normal,1:fast,2:slow
            writeD( 0 );
            writeH( 0 );
            writeS( pet.getNameId() );
            writeS( pet.getTitle() );
            writeC( 0 ); // 獣獣艦砺 - 0:mob, item(atk pointer) , 1:poisoned() ,
            // 2:invisable() , 4:pc, 8:cursed() , 16:brave() ,
            // 32:??, 64:??(??) , 128:invisable but name
            writeD( 0 ); // ??
            writeS( null ); // ??
            writeS( pet.getMaster() != null ? pet.getMaster().getName() : "" );
            writeC( 0 ); // ??
            writeC( 0xFF );
            writeC( 0 );
            writeC( pet.getLevel() ); // PC = 0, Mon = Lv
            writeC( 0 );
            writeC( 0xFF );
            writeC( 0xFF );
        }

        override
        public byte[] getContent()
        {
            if ( _byte == null )
            {
                _byte = _bao.ToArray();
            }

            return _byte;
        }

        override
        public String getType()
        {
            return "[S] S_DollPack";
        }
    }
}